package cn.mafangui.hotel.utils;

import cn.mafangui.hotel.enums.ExceptionEnum;
import cn.mafangui.hotel.exception.HotelException;
import org.springframework.util.ObjectUtils;

/**
 * @author kalpa
 * @date 2022/3/17 15:55
 * @description 断言
 */
public class AssertUtils {

    public static void assertNotNull(Object o, ExceptionEnum exceptionEnum) throws HotelException {
        if(ObjectUtils.isEmpty(o)){
            throw new HotelException(exceptionEnum);
        }
    }

    public static void assertTrue(boolean b, ExceptionEnum exceptionEnum) throws HotelException {
        if(!b){
            throw new HotelException(exceptionEnum);
        }
    }

    public static void assertFalse(boolean b, ExceptionEnum exceptionEnum) throws HotelException {
        if(b){
            throw new HotelException(exceptionEnum);
        }
    }
}
